# -*- coding: utf-8 -*-

"""
  @author: tangliqi
  @date: 2024/3/1 14:42
  @python version: 3.6 
  @contact me: 110
  ---------------------------------------
  @desc: stock => individual_stock.py 个股相关的函数方法
"""
import akshare as ak

from utils.dataframe_func import round_float_length


# 获取个股的流通股东
def stock_shareholders(stock_code: str):
    stock_circulate_stock_holder_df = ak.stock_circulate_stock_holder(symbol=stock_code)
    return stock_circulate_stock_holder_df.to_dict("records")


# 获取个股的主要股东
def main_stock_shareholders(stock_code: str):
    stock_main_stock_holder_df = ak.stock_main_stock_holder(stock=stock_code)
    stock_main_stock_holder_df = stock_main_stock_holder_df.fillna(0)
    stock_main_stock_holder_df = round_float_length(stock_main_stock_holder_df)

    return stock_main_stock_holder_df.to_dict("records")


# 查询个股信息
def individual_stock_info(stock_code: str):
    stock_individual_info_em_df = ak.stock_individual_info_em(symbol=stock_code)
    return stock_individual_info_em_df.to_dict("records")
